android studio mail gönderme kodu çalışırken runtime hatası
Arkadaslar kodlarım aşağıda. mail göndermeye çalışıyorum. çalışırken tam göndereceği sırada durduruldu şeklinde runtime hatası alıyorum.
hatayı tam olarak verdiği yer
mail.setContent(“Metin”,”textplain”);
satırı
bu satıra gelince uygulama patlıyo.
kodum şöyle
public class maildenemejava extends Fragment {
Session session=null;
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub
View view = inflater.inflate(R.layout.maildenemelayout, container,false);
Button gonder = (Button) view.findViewById(R.id.button9);
gonder.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { buttonClicked(v); } });
return view; }
public void buttonClicked (View view) {
Properties ozellik = new Properties();
ozellik.put("mail.transport.protocol", "smtp");
ozellik.put("mail.smtp.host", "mx1.hostinger.web.tr");
ozellik.put("mail.smtp.auth", "true");
ozellik.put("mail.smtp.port","587");
KullaniciBilgi kullaniciBilgi = new KullaniciBilgi();
Session mailSession = Session.getDefaultInstance(ozellik, kullaniciBilgi);
try{ Transport transport = mailSession.getTransport();
MimeMessage mail = new MimeMessage(mailSession);
mail.setContent("Metin","textplain");
mail.setFrom(new InternetAddress("info@temsili.xyz"));
mail.addRecipient(Message.RecipientType.TO, new InternetAddress("temsili@hotmail.com")); transport.connect();
transport.sendMessage(mail, mail.getRecipients(Message.RecipientType.TO));
transport.close();
Toast.makeText(getActivity(), "gönderili", Toast.LENGTH_LONG).show(); }
catch (Exception e) { e.printStackTrace(); } } }
logcat de bu şekilde
01-13 12:58:19.285 3005-3005/hop.com.meto E/AndroidRuntime: FATAL EXCEPTION: main
Process: hop.com.meto, PID: 3005
java.lang.NoClassDefFoundError: javax.activation.DataHandler
at javax.mail.internet.MimeMessage.setContent(MimeMessage.java:1566)
at hop.com.meto.maildenemejava.buttonClicked(maildenemejava.java:132)
at hop.com.meto.maildenemejava$1.onClick(maildenemejava.java:64)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)